﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class download : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string fp = Server.UrlDecode(Request.Params["fp"]);
        string fn=Server.UrlDecode(Request.Params["fn"]);
        System.IO.FileInfo file = new System.IO.FileInfo(fp);
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Charset = System.Text.Encoding.Default.ToString();
        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fn));
        HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
        HttpContext.Current.Response.ContentType = "application/octet-stream";
        HttpContext.Current.Response.WriteFile(file.FullName);
        HttpContext.Current.Response.End();
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.Clear();
    }
}
